<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
		<view>
			版本号为：{{vuex_version}}
		</view>
		<view>
			《琵琶行》的作者为{{vuex_user.name}}
		</view>
		<u-button @click="modifyVuex">修改变量</u-button>
		<u-icon name="huo" custom-prefix="custom-icon" size="30" color="#fa3534"></u-icon>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {
			// 调用getSearch接口
			this.$u.api.getSearch().then(res => {
				console.log(res)
			})

			// 调用getInfo接口
			this.$u.api.getInfo({
				id: 3
			}).then(res => {
				console.log(res)
			})
		},
		methods: {
			modifyVuex() {
				this.$u.vuex('vuex_version', '1.0.1')
				// 修改对象的形式，中间用"."分隔
				this.$u.vuex('vuex_user.name', '诗圣')
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
